import { fromJS } from "immutable"
import * as types from "./action-types"

const initData = fromJS({
    login: false,
    token: "",
    user: {}
})
export default (state = initData, action) => {
    switch (action.type) {
        case types.LOGIN:
            return state.merge({
                user: action.user,
                token: action.token,
                login: true
            })
        case types.LOGOUT:
            return state.merge({
                user: {},
                login: false,
                token: ""
            })
        default:
            return state;
    }
}